package com.wangsd.web.sys.mapper;

import com.gitee.fastmybatis.core.mapper.CrudMapper;
import com.wangsd.web.sys.entity.SysMenu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author generator
 * @since 2019-09-02
 */
public interface SysMenuMapper extends CrudMapper<SysMenu, Long> {

    @Select("SELECT * FROM sys_menu t left join sys_permission t2 on t.id = t2.access_id" +
            " where t2.access_type = 1 and t2.role_id = #{roleId}")
    List<SysMenu> selectByRoleId(Long roleId);

    @Update("update sys_menu set ${name} = #{value} where id = #{id}")
    int updateOther(@Param("id") Long id, @Param("name") String name, @Param("value") Object value);

}
